package com.guchenbo.example.rsa;

/**
 * @Author gucb
 * @Date 2017/5/11.
 */
public class RSATest {

    public static void testRsa() {
        try {
            RSAUtils.initKeyPair();

            String publicKey = RSAUtils.getPublicKey();
            String privateKey = RSAUtils.getPrivateKey();

            String data = "chenbo.gu@tongdun.cn";

            System.out.println("原始：" + data);
            String ds = RSAUtils.encryptByPublic(data, publicKey);
            System.out.println("加密：" + ds);
            System.out.println("解密：" + RSAUtils.decryptByPrivate(ds, privateKey));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String args[]) {
        testRsa();
    }
}
